package com.five.api;

import com.five.dto.CollectionDto;
import com.five.dto.IdRequest;
import com.five.pojo.Comment;
import com.five.pojo.Reader;
import com.five.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

import java.util.List;
import java.util.Set;

@FeignClient(name = "reader-service")
public interface ReaderServiceAPI {
    @PostMapping("/reader/queryByPhone/{phone}")
    Result<Reader> queryByPhone(@PathVariable String phone);

    @PostMapping("/reader/queryByEmail/{email}")
    Result<Reader> queryByEmail(@PathVariable String email);

    @PostMapping("/reader/queryByLoginInfoId/{loginInfoId}")
    Result<Reader> queryByLoginInfoId(@PathVariable Long loginInfoId);

    @PostMapping("/reader/insertReader")
    Result insertReader(@RequestBody Reader reader);

    @PostMapping("/reader/updateReader")
    Result updateReader(@RequestBody Reader reader);

    /**
     * 根据账号查询读者信息
     *
     * @param
     * @return
     */
    @PostMapping("/reader/queryByAccount/{account}")
    public Result<Reader> queryByAccount(@PathVariable String account);


    /*
     * 取消收藏
     * @param token 登陆人token
     * @param novelId 书籍ID
     * */
    @PostMapping("/collect/add")
    Result<Void> addCollect(@RequestHeader("token") String token, Long novelId);

    /*
     * 取消收藏
     * @param token 登陆人token
     * @param novelId 书籍ID
     * */
    @PostMapping("/collect/cancel")
    Result<Void> cancelCollect(@RequestHeader("token") String token, Long novelId);

    /*
     * 书架，查询用户收藏的书籍ID列表
     * @param token 登陆人token
     * */
    @PostMapping("/reader/bookshelf")
    Result<Set<Long>> getReaderCollectNovelIds(@RequestHeader("token") String token);

    /**
     * 根据小说id查询读者对该书的评论及回复
     */
    @PostMapping("/reader/books/comments")
    Result<List<Comment>> getBooksWithComments(@RequestBody IdRequest request);

    /**
     * 根据commentId更新评论的回复数量
     */
    @PostMapping("/reader/update-reply-count")
    Result<Void> updateReplyCount(@RequestBody IdRequest request);
}